package com.tide.crm.dao;

import com.tide.crm.model.ProjectFollowInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * (ProjectFollowInfo)表数据库访问层
 *
 * @author makejava
 * @since 2021-03-15 16:43:50
 */
@Mapper
public interface ProjectFollowInfoDao {

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    ProjectFollowInfo queryById(Long id);

    /**
     * 查询指定行数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    List<ProjectFollowInfo> queryAllByLimit(@Param("offset") int offset, @Param("limit") int limit);


    /**
     * 通过实体作为筛选条件查询
     *
     * @param projectFollowInfo 实例对象
     * @return 对象列表
     */
    List<ProjectFollowInfo> queryAll(ProjectFollowInfo projectFollowInfo);

    /**
     * 新增数据
     *
     * @param projectFollowInfo 实例对象
     * @return 影响行数
     */
    int insert(ProjectFollowInfo projectFollowInfo);

    /**
     * 批量新增数据（MyBatis原生foreach方法）
     *
     * @param entities List<ProjectFollowInfo> 实例对象列表
     * @return 影响行数
     */
    int insertBatch(@Param("entities") List<ProjectFollowInfo> entities);

    /**
     * 批量新增或按主键更新数据（MyBatis原生foreach方法）
     *
     * @param entities List<ProjectFollowInfo> 实例对象列表
     * @return 影响行数
     */
    int insertOrUpdateBatch(@Param("entities") List<ProjectFollowInfo> entities);

    /**
     * 修改数据
     *
     * @param projectFollowInfo 实例对象
     * @return 影响行数
     */
    int update(ProjectFollowInfo projectFollowInfo);

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 影响行数
     */
    int deleteById(Long id);


    @Select("select * from project_follow_info t where t.id = #{id}")
    ProjectFollowInfo getById(Long id);

    @Delete("delete from project_follow_info where id = #{id}")
    int delete(Long id);


    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into project_follow_info(id,approval_time, project_number, entry_name, project_location, project_amount, integrator_name, user_name, user_scenarios, main_products, specifications, number, bidding_mode, bidding_time, success_rate, project_debriefing, friend_business, competitive_pro_info, estimate_landing_time, estimated_installation_time, failure_and_reasons, remark, create_date,  modify_date,creater,modifyer) values(#{id},#{approvalTime}, #{projectNumber}, #{entryName}, #{projectLocation}, #{projectAmount}, #{integratorName}, #{userName}, #{userScenarios}, #{mainProducts}, #{specifications}, #{number}, #{biddingMode}, #{biddingTime}, #{successRate}, #{projectDebriefing}, #{friendBusiness}, #{competitiveProInfo}, #{estimateLandingTime}, #{estimatedInstallationTime}, #{failureAndReasons}, #{remark}, now(), now(),#{creater},#{modifyer})")
    int save(ProjectFollowInfo projectFollowInfo);

    int count(@Param("params") Map<String, Object> params);

    List<ProjectFollowInfo> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);

}